package com.bindingfly.client.formrender.widget.impl;

import java.util.HashMap;

import com.bindingfly.client.formrender.WidgetInjecterPojo;
import com.bindingfly.client.formrender.widget.types.InjectableContainer;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

public class SimplePanelFly implements InjectableContainer
{

	@Override
	public boolean doesRequirePostProcessExecution()
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void executePostProcess(Widget widget, HashMap<String, WidgetInjecterPojo> renderedWidgets)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public Widget init(Element seedElement)
	{
		SimplePanel panel = new SimplePanel();
		
		String html = seedElement.getInnerHTML();
		seedElement.setInnerHTML("");
		panel.add(new HTMLPanel(html));
		
		panel.setTitle(seedElement.getAttribute("widgetTitle"));
		
		String width = seedElement.getAttribute("widgetWidth");
		if (width != null && width.length() > 0)
		{
			panel.setWidth(width);
		}

		String height = seedElement.getAttribute("widgetHeight");
		if (height != null && height.length() > 0)
		{
			panel.setHeight(height);
		}
		
		return panel;
	}

	@Override
	public boolean needKnowledgeOfChildren()
	{
		return false;
	}

	@Override
	public HTMLPanel getHtmlPanel(Widget initatedContainerWidget, int index)
	{
		return (HTMLPanel)((SimplePanel)initatedContainerWidget).getWidget();
	}

	@Override
	public int htmlPanelCount(Widget initatedContainerWidget)
	{
		return 0;
	}

	@Override
	public void populateChildrenWidgets(Widget initatedContainerWidget, HashMap<String, WidgetInjecterPojo> children)
	{
		// TODO Auto-generated method stub
	}

	@Override
	public String getSubmitableValue(Widget widget)
	{
		return null;
	}





}
